package com.ems.controller;

import com.ems.service.IBatteryBoxService;
import com.ems.vo.BaseResult;
import com.ems.vo.BatteryBoxVo;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 电池簇 前端控制器
 * </p>
 * @author WuZH
 * @since 2024-04-23
 */
@RestController
@RequestMapping ("/batteryBox")
@CrossOrigin (value = "*", maxAge = 3600)
public class BatteryBoxController {

    @Resource
    private IBatteryBoxService iBatteryBoxService;

    @RequestMapping ("queryList")
    public BaseResult queryList (@RequestBody BatteryBoxVo batteryBoxVo) {
        List<BatteryBoxVo> batteryBoxVos = iBatteryBoxService.queryList ( batteryBoxVo );
        return BaseResult.success ( batteryBoxVos, iBatteryBoxService.queryCount ( batteryBoxVo ) );
    }

    @RequestMapping ("saveSingle")
    public BaseResult saveSingle (@RequestBody BatteryBoxVo batteryBoxVo) {
        batteryBoxVo = iBatteryBoxService.saveSingle ( batteryBoxVo );
        return BaseResult.success ( batteryBoxVo );
    }

}
